class 控制台 {
    static 输出(欲输出内容) {
        console.log(欲输出内容);
    }

    static 输出行(欲输出内容) {
        console.log(欲输出内容);
    }

    static 输出格式文本(欲格式化文本, ...格式化参数) {
        console.log(欲格式化文本, 格式化参数);
    }
}


class JSON对象 {
    obj = {};

    constructor() {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 1) {
            this.obj = JSON.parse(JSON.stringify(args[0]));
        } else {
            this.obj = {};
        }
    }

    set JSON文本(文本) {
        this.obj = JSON.parse(文本);
    }

    get 键名() {
        return Object.keys(this.obj);
    }

    取文本(名称) {
        return this.obj[名称];
    }

    取逻辑值(名称) {
        return this.obj[名称];
    }

    取整数(名称) {
        return this.obj[名称];
    }

    取JSON对象(名称) {
        return new JSON对象(this.obj[名称]);
    }

    取JSON数组(名称) {
        return new JSON数组(this.obj[名称]);
    }

    添加项目(名称, 对应值) {
        this.obj[名称] = 对应值;
    }

    移除项目(名称) {
        delete this.obj[名称];
    }

    是否包含(名称) {
        return this.obj.hasOwnProperty(名称);
    }

    到文本() {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 1) {
            return JSON.stringify(this.obj, args[0]);
        } else {
            return JSON.stringify(this.obj);
        }
    }
}

class JSON数组 {
    array = [];

    constructor() {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 1) {
            this.array = JSON.parse(JSON.stringify(args[0]));
        } else {
            this.array = [];
        }
    }

    set JSON文本(文本) {
        this.array = JSON.parse(文本);
    }

    get 数组长度() {
        return this.array.length;
    }

    取文本(索引) {
        return this.array[索引];
    }

    取逻辑值(索引) {
        return this.array[索引];
    }

    取整数(索引) {
        return this.array[索引];
    }

    取JSON对象(索引) {
        return new JSON对象(this.array[索引]);
    }

    取JSON数组(索引) {
        return new JSON数组(this.array[索引]);
    }

    添加项目(索引, 值) {
        this.array[索引] = 值;
    }

    移除项目(索引) {
        this.array.splice(索引, 1);
    }

    到文本() {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 1) {
            return JSON.stringify(this.array, args[0]);
        } else {
            return JSON.stringify(this.array);
        }
    }
}

class 编码操作 {

    static URL编码(值) {
        return encodeURIComponent(值);
    }


    static URL解码(值) {
        return decodeURIComponent(值);
    }


    static 转换编码(待转换文本, 原编码, 新编码) {
        if (!待转换文本) {
            return "";
        }
        try {
            return new TextDecoder(新编码).decode(new TextEncoder().encode(待转换文本));
        } catch (e) {
            return "";
        }
    }


    static UCS2编码(值) {
        let str = "";
        for (let i = 0; i < 值.length; i++) {
            let temp = 值.charCodeAt(i).toString(16);
            if (temp.length === 2) {
                temp = "00" + temp;
            }
            str += "\\u" + temp;
        }
        return str;
    }


    static UCS2解码(值) {
        let len = 值.length;
        let outBuffer = [];
        let x = 0;
        while (x < len) {
            let aChar = 值.charAt(x);
            if (aChar === '\\') {
                x++;
                aChar = 值.charAt(x);
                if (aChar === 'u') {
                    let value = 0;
                    for (let i = 0; i < 4; i++) {
                        x++;
                        aChar = 值.charAt(x);
                        value = value * 16 + parseInt(aChar, 16);
                    }
                    outBuffer.push(String.fromCharCode(value));
                } else {
                    if (aChar === 't') {
                        aChar = '\t';
                    } else if (aChar === 'r') {
                        aChar = '\r';
                    } else if (aChar === 'n') {
                        aChar = '\n';
                    } else if (aChar === 'f') {
                        aChar = '\f';
                    }
                    outBuffer.push(aChar);
                }
            } else {
                outBuffer.push(aChar);
            }
            x++;
        }
        return outBuffer.join('');
    }
}
class 共享数据 {

    static 初始化数据() {
        共享数据.sp = window.localStorage;
    }


    static 是否包含数据(键) {
        return 共享数据.sp.getItem(键) !== null;
    }


    static 移除数据(键) {
        共享数据.sp.removeItem(键);
        return true;
    }


    static 清除数据() {
        共享数据.sp.clear();
        return true;
    }


    static 取文本(键, 默认值 = '') {
        const 值 = 共享数据.sp.getItem(键);
        return 值 !== null ? 值 : 默认值;
    }


    static 置文本(键, 值) {
        共享数据.sp.setItem(键, 值.toString());
        return true;
    }


    static 置整数(键, 值) {
        共享数据.sp.setItem(键, 值.toString());
        return true;
    }


    static 取整数(键, 默认值 = 0) {
        const 值 = parseInt(共享数据.sp.getItem(键), 10);
        return !isNaN(值) ? 值 : 默认值;
    }


    static 置浮点数(键, 值) {
        共享数据.sp.setItem(键, 值.toString());
        return true;
    }


    static 取浮点数(键, 默认值 = 0.0) {
        const 值 = parseFloat(共享数据.sp.getItem(键));
        return !isNaN(值) ? 值 : 默认值;
    }


    static 置逻辑(键, 值) {
        共享数据.sp.setItem(键, 值.toString());
        return true;
    }


    static 取逻辑(键, 默认值 = false) {
        const 值 = 共享数据.sp.getItem(键);
        return 值 === 'true';
    }
}

class 加解密操作 {
    static MD5加密(值) {
        return md5(值);
    }

    static SHA加密(值) {
        return str_sha1(值);
    }

    static Base64编码(值) {
        return btoa(encodeURIComponent(值));
    }

    static Base64解码(值) {
        return decodeURIComponent(atob(值));
    }
}

class 媒体操作 {
    static mp = null;
    static 播放音乐(路径) {
        媒体操作.mp = new Audio(路径);
        媒体操作.mp.oncanplay = function() {
            媒体操作.mp.play();
        }
    }

    static 停止播放() {
        媒体操作.mp.pause();
    }

    static 暂停播放() {
        媒体操作.mp.pause();
    }

    static 继续播放() {
        媒体操作.mp.play();
    }

    static 取音乐时长() {
        return 媒体操作.mp.duration;
    }

    static 取播放位置() {
        return 媒体操作.mp.currentTime;
    }

    static 置播放位置(值) {
        return 媒体操作.mp.currentTime = 值;
    }

    static 置播放音量(音量) {
        return 媒体操作.mp.volume = 音量;
    }

    static 取播放状态() {
        return !媒体操作.mp.paused;
    }
}

class 拼音操作 {
    static pystr = ["a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian", "biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che", "chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan", "cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du", "duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang", "gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang", "hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian", "jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken", "keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng", "li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai", "man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai", "nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan", "nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu", "qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re", "ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha", "shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun", "shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao", "tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi", "xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi", "yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha", "zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui", "zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"];
    static pyvalue = [-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728, -19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261, -19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961, -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, -17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692, -17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733, -16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419, -16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959, -15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631, -15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180, -15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941, -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, -14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094, -14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831, -13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329, -13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860, -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300, -12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358, -11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014, -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254];

    static getChsAscii(chs) {
        let asc = 0;
        try {
            let bytes = new TextEncoder().encode(chs);
            if (bytes.length > 2 || bytes.length === 0) {
                throw new Error("illegal resource string");
            }
            if (bytes.length === 1) {
                asc = bytes[0];
            }
            if (bytes.length !== 2) {
                return asc;
            }
            return (((bytes[0] + 256) * 256) + (bytes[1] + 256)) - 65536;
        } catch (e) {
            console.error(e);
            return 0;
        }
    }

    static 取汉字首拼(内容) {
        let py = this.取汉字拼音(内容);
        if (py.length > 1) {
            py = py.substring(0, 1);
        }
        return py;
    }

    static 取词组首拼(内容) {
        let buffer = [];
        for (let i = 0; i < 内容.length; i++) {
            let key = 内容.charAt(i);
            let value = key.length >= 2 ? this.取汉字首拼(key) : key;
            buffer.push(value);
        }
        return buffer.join('');
    }

    static 取汉字拼音(内容) {
        let result = "";
        let ascii = this.getChsAscii(内容);
        if (ascii > 0 && ascii < 160) {
            return String.fromCharCode(ascii);
        }
        for (let i = this.pyvalue.length - 1; i >= 0; i--) {
            if (this.pyvalue[i] <= ascii) {
                return this.pystr[i];
            }
        }
        return result;
    }

    static 取词组拼音(内容) {
        let buffer = [];
        for (let i = 0; i < 内容.length; i++) {
            let key = 内容.charAt(i);
            let value = key.length >= 2 ? this.取汉字拼音(key) : key;
            buffer.push(value);
        }
        return buffer.join('');
    }
}

class 时间操作 {
    static DATE_APRIL = 3;
    static DATE_AUGUST = 7;
    static DATE_DAY = 5;
    static DATE_DECEMBER = 11;
    static DATE_FEBRUARY = 1;
    static DATE_FRIDAY = 6;
    static DATE_HOUR = 11;
    static DATE_JANUARY = 0;
    static DATE_JULY = 6;
    static DATE_JUNE = 5;
    static DATE_MARCH = 2;
    static DATE_MAY = 4;
    static DATE_MINUTE = 12;
    static DATE_MONDAY = 2;
    static DATE_MONTH = 2;
    static DATE_NOVEMBER = 10;
    static DATE_OCTOBER = 9;
    static DATE_SATURDAY = 7;
    static DATE_SECOND = 13;
    static DATE_SEPTEMBER = 8;
    static DATE_SUNDAY = 1;
    static DATE_THURSDAY = 5;
    static DATE_TUESDAY = 3;
    static DATE_WEDNESDAY = 4;
    static DATE_WEEK = 3;
    static DATE_YEAR = 1;


    static 取格式时间(格式) {
        const 年 = 'yyyy';
        const 月 = 'MM';
        const 日 = 'dd';
        const 时 = 'HH';
        const 分 = 'mm';
        const 秒 = 'ss';

        const 当前时间 = new Date();


        let 格式化字符串 = 格式.replace(年, 当前时间.getFullYear());
        格式化字符串 = 格式化字符串.replace(月, ('0' + (当前时间.getMonth() + 1)).slice(-2));
        格式化字符串 = 格式化字符串.replace(日, ('0' + 当前时间.getDate()).slice(-2));
        格式化字符串 = 格式化字符串.replace(时, ('0' + 当前时间.getHours()).slice(-2));
        格式化字符串 = 格式化字符串.replace(分, ('0' + 当前时间.getMinutes()).slice(-2));
        格式化字符串 = 格式化字符串.replace(秒, ('0' + 当前时间.getSeconds()).slice(-2));

        return 格式化字符串;
    }


    static 时间戳到文本(时间戳, 时间格式文本) {
        const date = new Date(时间戳);
        const formatter = new Intl.DateTimeFormat('en', {
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit'
        });
        const parts = formatter.formatToParts(date);
        const map = new Map(parts.map(({
            type,
            value
        }) => [type, value]));
        return `${map.get('year')}-${map.get('month')}-${map.get('day')} ${map.get('hour')}:${map.get('minute')}:${map.get('second')}`;
    }


    static 取时间戳() {
        return Date.now();
    }


    static 取时间戳文本() {
        return Date.now().toString();
    }


    static 时间文本到时间戳(时间格式, 时间文本) {
        const format = new Intl.DateTimeFormat('en', {
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit'
        });
        const parts = 时间文本.split(/\D/);
        const [year, month, day, hour = 0, minute = 0, second = 0] = parts;
        const date = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
        return date.getTime();
    }


    static 到时间(时间戳) {
        try {
            return new Date(时间戳);
        } catch (error) {
            throw new Error('到时间( 参数错误');
        }
    }


    static 增减时间(时间对象, 增减部分, 时间值) {
        const date = new Date(时间对象);
        switch (增减部分) {
            case 1:
                date.setFullYear(date.getFullYear() + 时间值);
                break;
            case 2:
                date.setMonth(date.getMonth() + 时间值);
                break;
            case 3:
                date.setDate(date.getDate() + 时间值);
                break;
            case 4:
                date.setDate(date.getDate() + (时间值 * 7));
                break;
            case 5:
                date.setHours(date.getHours() + 时间值);
                break;
            case 6:
                date.setMinutes(date.getMinutes() + 时间值);
                break;
            case 7:
                date.setSeconds(date.getSeconds() + 时间值);
                break;
            default:
                break;
        }
        return date;
    }


    static 取日(时间对象) {
        return new Date(时间对象).getDate();
    }


    static 时间到文本(时间对象) {
        return new Date(时间对象).toLocaleString();
    }


    static 取小时(时间对象) {
        return new Date(时间对象).getHours();
    }


    static 取分钟(时间对象) {
        return new Date(时间对象).getMinutes();
    }


    static 取月份(时间对象) {
        return new Date(时间对象).getMonth() + 1;
    }


    static 取月份名称(时间对象) {
        return new Date(时间对象).toLocaleString('default', {
            month: 'long'
        });
    }


    static 取现行时间对象() {
        return new Date();
    }


    static 取秒(时间对象) {
        return new Date(时间对象).getSeconds();
    }


    static 取启动时间() {
        return Date.now();
    }


    static 取星期几(时间对象) {
        return new Date(时间对象).getDay() + 1;
    }


    static 取星期几名称(时间对象) {
        return new Date(时间对象).toLocaleString('default', {
            weekday: 'long'
        });
    }


    static 取年份(时间对象) {
        return new Date(时间对象).getFullYear();
    }


    static 取现行时间文本(内容) {
        const date = new Date();
        return `${date.getHours()}${内容}${date.getMinutes()}${内容}${date.getSeconds()}`;
    }


    static 取现行日期文本(内容) {
        const date = new Date();
        return `${date.getFullYear()}${内容}${date.getMonth() + 1}${内容}${date.getDate()}`;
    }


    static 取时间间隔(时间对象1, 时间对象2) {
        return new Date(时间对象1).getTime() - new Date(时间对象2).getTime();
    }


    static 取指定时间戳(时间对象, 类型) {
        const timestamp = new Date(时间对象).getTime().toString();
        if (类型 === 2) {
            return timestamp.substring(0, 10);
        }
        return timestamp;
    }


    static 时间戳到时间文本(时间戳) {
        if (!时间戳 || 时间戳 === '') {
            return '';
        }
        const stamp = 时间戳.length === 10 ? parseInt(时间戳) * 1000 : parseInt(时间戳);
        const date = new Date(stamp);
        return date.toLocaleString();
    }
}

class 数据库操作 {

    static #db = null;


    static 打开数据库 = (数据库名称) => {
        try {
            数据库操作.#db = openDatabase(数据库名称, '1.0', '数据库操作', 5 * 1024 * 1024);
        } catch (e) {
            throw new Error(`打开数据库失败：${e.message}`);
        }
    };


    static 关闭数据库 = () => {
        try {
            数据库操作.#db.close();
        } catch (e) {
            throw "关闭数据库失败： " + e;
        }
    };


    static 创建数据表 = (表名, 索引) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`CREATE TABLE IF NOT EXISTS ${表名} (${索引})`);
            });
        } catch (e) {
            throw '创建数据表失败：' + e;
        }
    };


    static 删除数据表 = (表名) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`DROP TABLE IF EXISTS ${表名}`);
            });
        } catch (e) {
            throw '删除数据表失败：' + e;
        }
    };


    static 插入记录 = (表名, 内容) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`INSERT INTO ${表名} VALUES (${内容})`);
            });
        } catch (e) {
            throw '插入记录失败：' + e;
        }
    };


    static 删除记录 = (表名, 条件) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`DELETE FROM ${表名} WHERE ${条件}`);
            });
        } catch (e) {
            throw '删除记录失败：' + e;
        }
    };


    static 修改记录 = (表名, 内容, ID) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`UPDATE ${表名} SET ${内容} WHERE ${ID}`);
            });
        } catch (e) {
            throw '修改记录失败：' + e;
        }
    };


    static 条件查询 = (表名, 筛选条件, 列分隔符, 行分隔符) => {
        let tmpvalue = '';
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`SELECT * FROM ${表名} WHERE ${筛选条件}`, [], (_, {
                rows
            }) => {
                for (let i = 0; i < rows.length; i++) {
                    let item = rows.item(i);
                    Object.keys(item).forEach((key) => {
                        tmpvalue += item[key] + 列分隔符;
                    });
                    tmpvalue += 行分隔符;
                }
            });
        });
        return tmpvalue;
    };


    static 范围查询 = (表名, 起始查询记录索引, 查询记录条数, 列分隔符, 行分隔符) => {
        let tmpvalue = '';
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`SELECT * FROM ${表名} LIMIT ${起始查询记录索引},${查询记录条数}`, [], (_, {
                rows
            }) => {
                for (let i = 0; i < rows.length; i++) {
                    let item = rows.item(i);
                    Object.keys(item).forEach((key) => {
                        tmpvalue += item[key] + 列分隔符;
                    });
                    tmpvalue += 行分隔符;
                }
            });
        });
        return tmpvalue;
    };


    static 查询最大值 = (表名, 字段名) => {
        let tmpvalue = 0;
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`SELECT max(${字段名}) FROM ${表名}`, [], (_, {
                rows
            }) => {
                tmpvalue = rows.item(0)[`max(${字段名})`];
            });
        });
        return tmpvalue;
    };


    static 数据库查询 = (SQL语句, 列分隔符, 行分隔符) => {
        let tmpvalue = '';
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(SQL语句, [], (_, {
                rows
            }) => {
                for (let i = 0; i < rows.length; i++) {
                    let item = rows.item(i);
                    Object.keys(item).forEach((key) => {
                        tmpvalue += item[key] + 列分隔符;
                    });
                    tmpvalue += 行分隔符;
                }
            });
        });
        return tmpvalue;
    };


    static 数据库执行 = (SQL语句) => {
        try {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(SQL语句);
            });
        } catch (e) {
            throw '执行SQL语句失败：' + e;
        }
    };


    static 取记录数 = (表名) => {
        let count = 0;
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`SELECT count(*) FROM ${表名}`, [], (_, {
                rows
            }) => {
                count = rows.item(0)['count(*)'];
            });
        });
        return count;
    };


    static 数据表是否存在 = async (表名) => {
        let count = 0;
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`SELECT count(*) FROM sqlite_master WHERE type='table' AND name='${表名}'`, [], (_, {
                rows
            }) => {
                count = rows.item(0)['count(*)'];
            });
        });
        return count > 0;
    };


    static 字段是否存在 = async (表名, 字段名) => {
        let result = false;
        数据库操作.#db.transaction((tx) => {
            tx.executeSql(`PRAGMA table_info(${表名})`, [], (_, {
                rows
            }) => {
                for (let i = 0; i < rows.length; i++) {
                    if (rows.item(i).name === 字段名) {
                        result = true;
                        break;
                    }
                }
            });
        });
        return result;
    };


    static 取所有数据表 = () => {
        return new Promise((resolve, reject) => {
            数据库操作.#db.transaction((tx) => {
                tx.executeSql(`SELECT name FROM sqlite_master WHERE type='table' ORDER BY name`, [], (_, {
                    rows
                }) => {
                    let result = [];
                    for (let i = 0; i < rows.length; i++) {
                        result.push(rows.item(i).name);
                    }
                    resolve(result);
                });
            });
        });
    };
}

class 数组操作 {

    static 过滤数组(数组, 内容, 包含与否) {
        let result = new Set();
        for (let a of 数组) {
            if ((a === 内容) === 包含与否) {
                result.add(a);
            }
        }
        return Array.from(result);
    }


    static 连接数组成员(数组, 连接符) {
        if (连接符 == null || 数组 == null) {
            return "";
        }
        let sb = "";
        let sep = "";
        for (let a of 数组) {
            sb += sep + a;
            sep = 连接符;
        }
        return sb;
    }


    static 取数组成员数(数组) {
        return 数组.length;
    }


    static 合并字节数组(字节数组1, 字节数组2) {
        if (字节数组1 == null && 字节数组2 != null) {
            return 字节数组2;
        }
        if (字节数组1 != null && 字节数组2 == null) {
            return 字节数组1;
        }
        if (字节数组1 == null && 字节数组2 == null) {
            return null;
        }
        let array3 = new Uint8Array(字节数组1.length + 字节数组2.length);
        array3.set(字节数组1, 0);
        array3.set(字节数组2, 字节数组1.length);
        return array3;
    }


    static 合并文本数组(数组1, 数组2) {
        if (数组1 == null && 数组2 != null) {
            return 数组2;
        }
        if (数组1 != null && 数组2 == null) {
            return 数组1;
        }
        if (数组1 == null && 数组2 == null) {
            return null;
        }
        return 数组1.concat(数组2);
    }


    static 复制数组(源数组, 复制位置, 目标数组, 粘贴位置, 粘贴个数) {
        if (源数组 && 目标数组) {
            目标数组.set(源数组.subarray(复制位置, 复制位置 + 粘贴个数), 粘贴位置);
        }
    }


    static 数组排序(数组) {
        if (数组 == null) {
            return [];
        }
        return 数组.sort((a, b) => a - b);
    }
}

class 算数运算 {
    static E = 2.718281828459045;
    static PI = 3.141592653589793;


    static 求反正切(值) {
        return Math.atan(值);
    }


    static 求余弦(值) {
        return Math.cos(值);
    }


    static 求反对数(值) {
        return Math.exp(值);
    }


    static 求自然对数(值) {
        return Math.log(值);
    }


    static 取随机数(最小值, 最大值) {
        return Math.floor(Math.random() * (最大值 + 1 - 最小值) + 最小值);
    }


    static 求正弦(值) {
        return Math.sin(值);
    }


    static 取符号(值) {
        return Math.sign(值);
    }


    static 求平方根(值) {
        return Math.sqrt(值);
    }


    static 求正切(值) {
        return Math.tan(值);
    }


    static 角度转弧度(值) {
        return Math.PI * 值 / 180.0;
    }


    static 弧度转角度(值) {
        return 值 * 180.0 / Math.PI;
    }


    static 四舍五入(数字, 精确度) {
        return Number(数字).toFixed(精确度);
    }


    static 求余数(数字1, 数字2) {
        return 数字1 % 数字2;
    }


    static 求反正弦(值) {
        return Math.asin(值);
    }


    static 求反余弦(值) {
        return Math.acos(值);
    }


    static 表达式计算(表达式) {
        let num = [];
        let flag = 0,
            begin = 0,
            end = 0,
            now = -1;
        let st = [];

        for (let i = 0; i < 表达式.length; i++) {
            let s = 表达式.charAt(i);
            if (s === ' ') {
                continue;
            } else if (s === '+' || s === '-' || s === '*' || s === '/' || s === '(' || s === ')' || s === '%') {
                if (flag === 1) {
                    now += 1;
                    if (end < begin) {
                        num[now] = parseInt(表达式.substring(begin, begin + 1));
                    } else {
                        num[now] = parseInt(表达式.substring(begin, end + 1));
                    }
                    flag = 0;
                }
                if (s === '-') {
                    if (i === 0 || 表达式.charAt(i - 1) === '(' || 表达式.charAt(i - 1) === '*' || 表达式.charAt(i - 1) === '/') {
                        flag = 1;
                        begin = i;
                    } else {
                        if (st.length === 0) {
                            st.push(s);
                        } else if (s === ')') {
                            num[now - 1] = compute(num[now - 1], num[now], st.pop());
                            now -= 1;
                            st.pop();
                        } else if (s === '(') {
                            st.push(s);
                        } else if (priority(s) <= priority(st[st.length - 1])) {
                            num[now - 1] = compute(num[now - 1], num[now], st.pop());
                            now -= 1;
                            st.push(s);
                        } else {
                            st.push(s);
                        }
                    }
                } else if (st.length === 0) {
                    st.push(s);
                } else if (s === ')') {
                    num[now - 1] = compute(num[now - 1], num[now], st.pop());
                    now -= 1;
                    st.pop();
                } else if (s === '(') {
                    st.push(s);
                } else if (priority(s) <= priority(st[st.length - 1])) {
                    num[now - 1] = compute(num[now - 1], num[now], st.pop());
                    now -= 1;
                    st.push(s);
                } else {
                    st.push(s);
                }
            } else if (flag === 0) {
                flag = 1;
                begin = i;
            } else {
                end = i;
            }
        }

        if (flag === 1) {
            now += 1;
            if (end < begin) {
                num[now] = parseInt(表达式.substring(begin, begin + 1));
            } else {
                num[now] = parseInt(表达式.substring(begin, end + 1));
            }
        }

        while (now > 0) {
            num[now - 1] = compute(num[now - 1], num[now], st.pop());
            now -= 1;
        }

        return num[0];
    }
}

function priority(s) {
    switch (s) {
        case '(':
        case ')':
            return 0;
        case '-':
        case '+':
            return 1;
        case '*':
        case '%':
        case '/':
            return 2;
        default:
            return -1;
    }
}

function compute(num1, num2, s) {
    switch (s) {
        case '(':
        case ')':
            return 0;
        case '-':
            return num1 - num2;
        case '+':
            return num1 + num2;
        case '%':
            return num1 % num2;
        case '*':
            return num1 * num2;
        case '/':
            return num1 / num2;
        default:
            return 0;
    }
}


class 网络操作 {
    headers = new Map();
    取网页源码结束 = () => {};
    取网页源码失败 = () => {};
    发送数据失败 = () => {};
    发送数据结束 = () => {};

    添加请求头(名称, 值) {


        if (!this.headers) {
            this.headers = new Map();
        }
        this.headers.set(名称, 值);
    }


    置请求头(请求头) {

        let strs1 = 请求头.split(",");
        for (let str of strs1) {
            let names = str.split("=");
            if (names.length === 2) {
                this.添加请求头(names[0], names[1]);
            }
        }
    }


    取请求头() {
        if (this.headers) {

            return JSON.stringify(Array.from(this.headers.entries()));
        }
        return "";
    }


    清除请求头() {
        if (this.headers) {
            this.headers.clear();
        }
    }


    async 取网页源码(网址, cookie = "", 编码 = "utf-8") {
        let headers = this.headers ? Object.fromEntries(this.headers.entries()) : {};
        let options = {
            method: 'GET',
            headers: headers,
        };
        if (cookie) {
            options.headers['Cookie'] = cookie;
        }
        try {
            let response = await fetch(网址, options);
            if (!response.ok) {
                throw new Error('网络请求失败');
            }
            let text = await response.text();

            this.取网页源码结束(text, response.headers.get('Set-Cookie'));
        } catch (error) {

            this.取网页源码失败(error.message);
        }
    }


    async 发送数据(网址, 数据, cookie = "", 编码 = "utf-8") {
        let headers = this.headers ? Object.fromEntries(this.headers.entries()) : {};
        let options = {
            method: 'POST',
            headers: {
                ...headers,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: 数据,
        };
        if (cookie) {
            options.headers['Cookie'] = cookie;
        }
        try {
            let response = await fetch(网址, options);
            if (!response.ok) {
                throw new Error('网络请求失败');
            }
            let text = await response.text();

            this.发送数据结束(text, response.headers.get('Set-Cookie'));
        } catch (error) {

            this.发送数据失败(error.message);
        }
    }
}

class 位运算 {

    static 位与(整数1, 整数2) {
        return 整数1 & 整数2;
    }


    static 位或(整数1, 整数2) {
        return 整数1 | 整数2;
    }


    static 位异或(整数1, 整数2) {
        return 整数1 ^ 整数2;
    }


    static 位非(整数1) {
        return 整数1 ^ -1;
    }


    static 位左移(整数1, 整数2) {
        return 整数1 << 整数2;
    }


    static 位右移(整数1, 整数2) {
        return 整数1 >> 整数2;
    }


    static 无符号位右移(整数1, 整数2) {
        return 整数1 >>> 整数2;
    }
}

class 文本操作 {

    static 寻找文本(文本, 寻找内容, 开始位置) {
        if (开始位置 < 0 || 开始位置 > 文本.length || 文本 === "" || 寻找内容 === "") {
            return -1;
        }
        return 文本.indexOf(寻找内容, 开始位置);
    }


    static 倒找文本(文本, 寻找内容, 开始位置) {
        if (开始位置 < 0 || 开始位置 > 文本.length || 文本 === "" || 寻找内容 === "") {
            return -1;
        }
        return 文本.lastIndexOf(寻找内容, 开始位置);
    }


    static 到大写(文本) {
        return 文本.toUpperCase();
    }


    static 到小写(文本) {
        return 文本.toLowerCase();
    }


    static 取指定字符(文本, 位置) {
        return 文本.charAt(位置);
    }


    static 取文本左边(文本, 长度) {
        if (文本 === "" || 长度 <= 0) {
            return "";
        }
        return 文本.substring(0, 长度 <= 文本.length ? 长度 : 文本.length);
    }


    static 取文本右边(文本, 长度) {
        if (文本 === "" || 长度 <= 0) {
            return "";
        }
        return 长度 <= 文本.length ? 文本.substring(文本.length - 长度, 文本.length) : 文本;
    }


    static 取文本中间(文本, 开始位置, 长度) {
        if (文本 === "" || 开始位置 < 0 || 长度 <= 0 || 开始位置 > 文本.length) {
            return "";
        }
        let end = 开始位置 + 长度;
        if (end > 文本.length) {
            end = 文本.length;
        }
        return 文本.substring(开始位置, end);
    }


    static 取文本长度(文本) {
        return 文本.length;
    }


    static 取文本长度2(文本) {
        return new Blob([文本]).size;
    }


    static 删首尾空(文本) {
        return 文本.trim();
    }


    static 删首空(文本) {
        let chars = 文本.split('');
        let count = 0;
        while (count < chars.length && chars[count] === ' ') {
            count++;
        }
        return chars.slice(count).join('');
    }


    static 删尾空(文本) {
        let chars = 文本.split('');
        let count = chars.length - 1;
        while (count >= 0 && chars[count] === ' ') {
            count--;
        }
        return chars.slice(0, count + 1).join('');
    }


    static 子文本替换(文本, 需替文本, 替换文本) {
        if (需替文本 === "" || 文本 === "") {
            return "";
        }
        return 文本.replace(new RegExp(需替文本.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'), 替换文本);
    }


    static 子文本替换2(文本, 开始位置, 结束位置, 替换文本) {
        if (文本 === "" || 开始位置 < 0 || 开始位置 > 文本.length || 结束位置 < 开始位置 || 结束位置 > 文本.length) {
            return "";
        }
        return 文本.substring(0, 开始位置) + 替换文本 + 文本.substring(结束位置 + 1);
    }


    static 文本比较(文本一, 文本二) {
        return 文本一.localeCompare(文本二);
    }


    static 翻转文本(文本) {
        return [...文本].reverse().join('');
    }


    static 分割文本(文本, 分割符) {
        if (分割符 === "" || 文本 === "") {
            return [];
        }
        if (分割符 === "\n") {
            文本 = this.子文本替换(文本, "\r", "");
        }
        if (文本.endsWith(分割符)) {
            return 文本.split(分割符);
        }
        return (分割符 + 文本 + 分割符).split(分割符);
    }


    static 取指定文本(文本, 开始文本, 结束文本) {
        if (文本 === "" || 开始文本 === "" || 结束文本 === "") {
            return [];
        }
        let regexp = new RegExp(`(?<=\\Q${开始文本}\\E).*?(?=\\Q${结束文本}\\E)`, 'g');
        return 文本.match(regexp) || [];
    }


    static 截取文本(文本, 开始文本, 结束文本) {
        let temp = this.取指定文本(文本, 开始文本, 结束文本);
        return temp.length > 0 ? temp[0] : "";
    }
}

class 颜色值操作 {

    static 到颜色值(alpha, red, green, blue) {
        return (alpha << 24) | (red << 16) | (green << 8) | blue;
    }


    static 取红色值(color) {
        return (color >> 16) & 0xFF;
    }


    static 取绿色值(color) {
        return (color >> 8) & 0xFF;
    }


    static 取蓝色值(color) {
        return color & 0xFF;
    }


    static 取透明度(color) {
        return (color >>> 24) & 0xFF;
    }
}

class 正则表达式 {
    constructor() {
        this.matcher = null;
        this.pattern = null;
    }


    static 正则匹配(文本, 表达式) {
        let mr = new RegExp(表达式, 'g');
        let list = [];
        let match;
        while ((match = mr.exec(文本)) !== null) {
            list.push(match[0]);
        }
        return list;
    }


    创建表达式(表达式, 敏感, 多行) {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 1) {
            this.pattern = new RegExp(表达式, 'g');
        } else {
            if (args[1] && args[2]) {
                this.pattern = new RegExp(表达式, 'gm');
            } else if (!args[1] && !args[2]) {
                this.pattern = new RegExp(表达式, 'g');
            } else if (args[1] && !args[2]) {
                this.pattern = new RegExp(表达式, 'm');
            } else if (!args[1] && args[2]) {
                this.pattern = new RegExp(表达式, 'g');
            }
        }
    }


    全部分割(文本) {
        if (this.pattern) {
            return 文本.split(this.pattern);
        }
        return [];
    }


    开始匹配(文本) {
        if (this.pattern) {
            this.matcher = 文本.matchAll(this.pattern);
        }
    }


    全部替换(文本) {
        if (this.matcher) {
            return 文本.replace(this.pattern, 文本);
        }
        return "";
    }


    匹配下一个() {
        if (this.matcher) {
            return !this.matcher.next().done;
        }
        return false;
    }


    取匹配文本() {
        if (this.matcher) {
            return this.matcher[0];
        }
        return "";
    }


    取匹配开始位置() {
        if (this.matcher) {
            return this.matcher.index;
        }
        return 0;
    }


    取匹配结束位置() {
        if (this.matcher) {
            return this.matcher.lastIndex;
        }
        return 0;
    }


    取子匹配数量() {
        return this.matcher.length;
    }


    取子匹配文本(索引) {
        if (this.matcher && this.matcher.length > 索引) {
            return this.matcher[索引];
        }
        return "";
    }
}

class 转换操作 {

    static 转换时长(时长) {
        if (Math.floor(时长 / 1000) % 60 < 10) {
            return `${Math.floor(时长 / 1000 / 60)}:0${Math.floor(时长 / 1000) % 60}`;
        } else {
            return `${Math.floor(时长 / 1000 / 60)}:${Math.floor(时长 / 1000) % 60}`;
        }
    }


    static 转换文件大小(大小) {
        let 大小2 = `${大小}B`;
        if (大小 > 1024 * 1024) {
            大小2 = `${(大小 / (1024 * 1024)).toFixed(2)} MB`;
        }
        return 大小2;
    }


    static 中文转unicode(值) {
        let utfBytes = [];
        for (let i = 0; i < 值.length; i++) {
            let hexB = 值.charCodeAt(i).toString(16);
            if (hexB.length <= 2) {
                hexB = '00' + hexB;
            }
            utfBytes.push(`\\u${hexB}`);
        }
        return utfBytes.join('');
    }


    static unicode转中文(值) {
        let pattern = /(\\u([\da-fA-F]{4}))/g;
        return 值.replace(pattern, function(match, group1) {
            return String.fromCharCode(parseInt(group1, 16));
        });
    }


    static 字符转代码(字符) {
        if (字符.length >= 1) {
            return 字符.charCodeAt(0);
        }
        throw new Error('字符转代码: 字符长度应该大于等于1');
    }


    static 代码转字符(代码) {
        return String.fromCharCode(代码);
    }


    static 到十六进制(值) {
        let 文本 = 值.toString(16);
        if (文本.length < 2) {
            文本 = '0' + 文本;
        }
        return 文本;
    }


    static 到十进制(值) {
        if (值 !== '') {
            return parseInt(值, 16);
        }
        return 0;
    }


    static 到二进制(值) {
        return 值.toString(2);
    }


    static 文本到二进制(值) {
        let strChar = 值.split('');
        let result = '';
        for (let i = 0; i < strChar.length; i++) {
            result += strChar[i].charCodeAt(0).toString(2) + ' ';
        }
        return result.trim();
    }


    static 字节到文本(值) {
        return String.fromCharCode.apply(null, 值);
    }


    static 字节到文本编码(值, 编码) {
        try {
            return new TextDecoder(编码).decode(值);
        } catch (ex) {
            console.error(ex);
            return null;
        }
    }


    static 文本到字节(值) {
        return new TextEncoder().encode(值);
    }


    static 文本到字节编码(值, 编码) {
        try {
            return new TextEncoder().encode(值);
        } catch (ex) {
            console.error(ex);
            throw new Error('文本到字节: 解码错误');
        }
    }


    static 字节到整数(值) {
        let targets = (值[0] & 0xFF) | (值[1] << 8 & 0xFF00) | (值[2] << 24 >>> 8) | (值[3] << 24);
        return targets;
    }


    static 整数到字节(值) {
        let targets = new Uint8Array(4);
        targets[0] = (值 & 0xFF);
        targets[1] = (值 >> 8 & 0xFF);
        targets[2] = (值 >> 16 & 0xFF);
        targets[3] = (值 >>> 24);
        return targets;
    }


    static 字节到长整数(值) {
        return (值[0] & 0xFF) << 56 | (值[1] & 0xFF) << 48 | (值[2] & 0xFF) << 40 | (值[3] & 0xFF) << 32 | (值[4] & 0xFF) << 24 | (值[5] & 0xFF) << 16 | (值[6] & 0xFF) << 8 | (值[7] & 0xFF) << 0;
    }


    static 长整数到字节(值) {
        let bb = new Uint8Array(8);
        bb[0] = (值 >> 56) & 0xFF;
        bb[1] = (值 >> 48) & 0xFF;
        bb[2] = (值 >> 40) & 0xFF;
        bb[3] = (值 >> 32) & 0xFF;
        bb[4] = (值 >> 24) & 0xFF;
        bb[5] = (值 >> 16) & 0xFF;
        bb[6] = (值 >> 8) & 0xFF;
        bb[7] = (值) & 0xFF;
        return bb;
    }


    static 数值到金额(值) {
        if (值 > 1.0E+18 || 值 < -1.0E+18) {
            return '';
        }
        const chineseDigits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
        let negative = false;
        if (值 < 0.0) {
            negative = true;
            值 *= -1.0;
        }
        let temp = Math.round(值 * 100.0);
        let numFen = temp % 10;
        temp = Math.floor(temp / 10);
        let numJiao = temp % 10;
        temp = Math.floor(temp / 10);
        let parts = [];
        let numParts = 0;
        while (temp !== 0) {
            let part = temp % 10000;
            parts.push(part);
            numParts++;
            temp = Math.floor(temp / 10000);
        }
        let beforeWanIsZero = true;
        let chineseStr = '';
        for (let i = 0; i < numParts; i++) {
            let partChinese = this.partTranslate(parts[i]);
            if (i % 2 === 0) {
                if (partChinese === '') {
                    beforeWanIsZero = true;
                } else {
                    beforeWanIsZero = false;
                }
            }
            if (i !== 0) {
                if (i % 2 === 0) {
                    chineseStr = `亿${chineseStr}`;
                } else if (partChinese === '' && !beforeWanIsZero) {
                    chineseStr = `零${chineseStr}`;
                } else {
                    if (parts[i - 1] < 1000 && parts[i - 1] > 0) {
                        chineseStr = `零${chineseStr}`;
                    }
                    chineseStr = `万${chineseStr}`;
                }
            }
            chineseStr = partChinese + chineseStr;
        }
        if (chineseStr === '') {
            chineseStr = chineseDigits[0];
        } else if (negative) {
            chineseStr = `负${chineseStr}`;
        }
        chineseStr += '元';
        if (numFen === 0 && numJiao === 0) {
            chineseStr += '整';
        } else if (numFen === 0) {
            chineseStr += `${chineseDigits[numJiao]}角`;
        } else if (numJiao === 0) {
            chineseStr += `零${chineseDigits[numFen]}分`;
        } else {
            chineseStr += `${chineseDigits[numJiao]}角${chineseDigits[numFen]}分`;
        }
        return chineseStr;
    }


    static 字节集到十六进制(值) {
        let hex = '0123456789ABCDEF';
        let buff = new Uint8Array(2 * 值.length);
        for (let i = 0; i < 值.length; i++) {
            buff[2 * i] = hex[(值[i] >> 4) & 0xF];
            buff[2 * i + 1] = hex[值[i] & 0xF];
        }
        return String.fromCharCode.apply(null, buff);
    }


    static 十六进制到字节集(值) {
        let b = new Uint8Array(值.length / 2);
        let j = 0;
        for (let i = 0; i < b.length; i++) {
            let c0 = 值.charAt(j++);
            let c1 = 值.charAt(j++);
            b[i] = (parseInt(c0, 16) << 4 | parseInt(c1, 16));
        }
        return b;
    }

    static partTranslate(amountPart) {
        if (amountPart < 0 || amountPart > 10000) {
            return '';
        }
        const chineseDigits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
        const units = ['', '拾', '佰', '仟'];
        let temp = amountPart;
        let amountStr = amountPart.toString();
        let amountStrLength = amountStr.length;
        let lastIsZero = true;
        let chineseStr = '';
        for (let i = 0; i < amountStrLength && temp !== 0; i++) {
            let digit = temp % 10;
            if (digit === 0) {
                if (!lastIsZero) {
                    chineseStr = `零${chineseStr}`;
                }
                lastIsZero = true;
            } else {
                chineseStr = `${chineseDigits[digit]}${units[i]}${chineseStr}`;
                lastIsZero = false;
            }
            temp = Math.floor(temp / 10);
        }
        return chineseStr;
    }
}

class 字符操作 {

    static 是否为数字(字符) {
        return /^\d$/.test(字符);
    }


    static 是否为字母(字符) {
        return /^[a-zA-Z]$/.test(字符);
    }


    static 是否为字母或数字(字符) {
        return /^[a-zA-Z0-9]$/.test(字符);
    }


    static 是否为空格(字符) {
        return /^\s$/.test(字符);
    }


    static 是否为大写字母(字符) {
        return /^[A-Z]$/.test(字符);
    }


    static 是否为小写字母(字符) {
        return /^[a-z]$/.test(字符);
    }


    static 到大写字母(字符) {
        return 字符.toUpperCase();
    }


    static 到小写字母(字符) {
        return 字符.toLowerCase();
    }
}

class 压缩操作 {
    static async zip压缩(zip) {
        return (await zip.generateAsync({
            type: "blob"
        }));
    }

    static async zip解压(zip, blob) {
        const zipData = await zip.loadAsync(zipBlob);
        return zipData;
    }

    static 创建zip() {
        return new JSZip();
    }

    static 添加文件(zip, 名称, 内容) {
        zip.file(名称, 内容);
    }

    static 添加文件夹(zip, 名称) {
        zip.folder(名称);
    }
}

class 哈希表 extends Map {
    constructor() {
        super();
        this.iterator = null;
    }


    添加项目(欲添加项目键名称, 欲添加项目值) {
        this.set(欲添加项目键名称, 欲添加项目值);
        this.iterator = this.keys();
    }


    取文本项目(键名称) {
        return this.get(键名称);
    }


    取项目(欲取项目键名称) {
        if (this.has(欲取项目键名称)) {
            return this.get(欲取项目键名称);
        } else {
            throw new Error("哈希表取项目错误");
        }
    }


    取项目总数() {
        return this.size;
    }


    是否包含(键名称) {
        return this.has(键名称);
    }


    删除项目(欲删除项目键名称) {
        this.delete(欲删除项目键名称);
        this.iterator = this.keys();
    }


    清空() {
        this.clear();
        this.iterator = this.keys();
    }


    下一个() {
        return this.iterator.next().value;
    }


    到起始位置() {
        this.iterator = this.keys();
    }


    是否有下一个() {
        return !this.iterator.done;
    }
}

class 有序哈希表 extends Map {
    constructor() {
        super();
        this.keysArray = [];
        this.iterator = null;
    }

    添加项目(欲添加项目键名称, 欲添加项目值) {
        this.set(欲添加项目键名称, 欲添加项目值);
        this.iterator = this.keysArray[Symbol.iterator]();
    }

    取文本项目(键名称) {
        return this.get(键名称);
    }

    取项目(欲取项目键名称) {
        return this.get(欲取项目键名称);
    }

    取项目总数() {
        return this.size;
    }

    是否包含(键名称) {
        return this.has(键名称);
    }

    删除项目(欲删除项目键名称) {
        this.delete(欲删除项目键名称);
        this.iterator = this.keysArray[Symbol.iterator]();
    }

    清空() {
        super.clear();
        this.keysArray = [];
        this.iterator = null;
    }

    下一个() {
        return this.iterator.next().value;
    }

    到起始位置() {
        this.iterator = this.keysArray[Symbol.iterator]();
    }

    是否有下一个() {
        return !this.iterator.done;
    }
}

class 集合 extends Array {

    constructor() {
        super();
    }


    添加项目(项目) {
        this.push(项目);
    }


    删除项目(索引) {
        this.splice(索引, 1);
    }


    取文本项目(索引) {
        try {
            return String(this[索引]);
        } catch (e) {
            throw new Error("取文本项目错误");
        }
    }


    取项目(索引) {
        try {
            return this[索引];
        } catch (e) {
            throw new Error("集合取项目错误: 索引超过集合下标");
        }
    }


    到文本数组() {
        return this.map(item => String(item));
    }


    到数组() {
        return Array.from(this);
    }


    取项目总数() {
        return this.length;
    }


    打乱顺序() {
        let currentIndex = this.length,
            temporaryValue, randomIndex;

        while (0 !== currentIndex) {
            randomIndex = Math.floor(Math.random() * currentIndex);
            currentIndex -= 1;

            temporaryValue = this[currentIndex];
            this[currentIndex] = this[randomIndex];
            this[randomIndex] = temporaryValue;
        }
    }


    插入项目(欲插入索引, 欲插入项目) {
        this.splice(欲插入索引, 0, 欲插入项目);
    }


    置项目(项目索引, 欲重设置项目) {
        if (项目索引 < this.length) {
            this[项目索引] = 欲重设置项目;
        }
    }


    是否为空() {
        return this.length === 0;
    }


    是否包含(项目) {
        return this.includes(项目);
    }


    查找项目索引(项目) {
        return this.indexOf(项目);
    }


    查找项目索引_逆序(项目) {
        return this.lastIndexOf(项目);
    }


    清空() {
        this.length = 0;
    }
}

function 到文本(值) {
    if (typeof 值 === 'string') {
        return 值;
    } else if (值 instanceof Error) {
        return 值.stack;
    } else if (Array.isArray(值)) {
        return JSON.stringify(值);
    } else {
        return String(值);
    }
}


function 格式化文本(欲格式化文本, ...格式化参数) {
    return 欲格式化文本.replace(/%s/g, () => 格式化参数.shift()).replace(/%d/g, () => 格式化参数.shift());
}


function 到数值(值) {
    try {
        return parseFloat(值);
    } catch (e) {
        throw new Error("到数值错误，无法将对应值转换为小数");
    }
}


function 到整数(值) {
    if (typeof 值 === 'string') {
        return parseInt(值, 10);
    } else if (typeof 值 === 'number') {
        return Math.floor(值);
    } else {
        throw new Error("到整数错误，无法将对应值转换为整数");
    }
}


function 到长整数(值) {
    if (typeof 值 === 'string') {
        return BigInt(值);
    } else if (typeof 值 === 'number') {
        return BigInt(Math.floor(值));
    } else {
        throw new Error("到长整数错误，无法将对应值转换为长整数");
    }
}

class TTS {
    constructor(end, onerror) {
        this.mSpeech = new SpeechSynthesisUtterance();
        this.mSpeech.onend = this.handleSpeechEnd.bind(this);
        this.mSpeech.onerror = this.handleSpeechError.bind(this);
        this.mSpeech.lang = 'zh-CN';
        this.mSpeech.rate = 1.0;
        this.mSpeech.pitch = 1.0;
        this.end = end;
        this.onerror = onerror;

        this.map = {
            '中文': 'zh-CN',
            '英语': 'en-US',
            '德语': 'de-DE',
            '法语': 'fr-FR',
            '日语': 'ja-JP'
        };


        this.setLanguage('中文');
    }

    set 语速(value) {
        this.mSpeech.rate = value;
    }

    set 音调(value) {
        this.mSpeech.pitch = value;
    }

    set 语言(value) {
        this.setLanguage(value);
    }

    get 朗读状态() {
        return window.speechSynthesis.speaking;
    }

    朗读文本(text) {
        this.mSpeech.text = text;
        window.speechSynthesis.speak(this.mSpeech);
    }

    关闭() {
        window.speechSynthesis.cancel();
    }

    停止() {
        window.speechSynthesis.cancel();
    }

    handleSpeechEnd() {

        this.end();
    }

    handleSpeechError(event) {

        this.onerror(event.error);
    }

    setLanguage(language) {
        if (this.map.hasOwnProperty(language)) {
            this.mSpeech.lang = this.map[language];
        } else {
            console.warn(`不支持的语言选项：${language}，默认使用中文。`);
            this.mSpeech.lang = 'zh-CN';
        }
    }
}

String.prototype.等同于 = function(欲判断相等文本) {
    return (this == 欲判断相等文本);
}
String.prototype.包含 = function(欲判断包含文本) {
    return this.includes(欲判断包含文本);
}
String.prototype.结尾为 = function(欲判断文本) {
    return this.endsWith(欲判断文本);
}
String.prototype.开头为 = function(欲判断文本) {
    return this.startsWith(欲判断文本);
}
String.prototype.取文本长度 = function() {
    return this.length;
}
String.prototype.为空 = function() {
    return (this == null || this == undefined || this == "");
}
String.prototype.替换 = function(欲替换文本, 欲替换到文本) {
    return 文本操作.子文本替换(this, 欲替换文本, 欲替换到文本);
}
String.prototype.分割 = function(分割符) {
    return this.split(分割符);
}

class 方向传感器 {
    constructor(方向改变) {
        this.enabled = true;
        this.pitch = 0;
        this.roll = 0;
        this.yaw = 0;

        window.addEventListener('deviceorientation', (event) => {
            if (this.enabled) {
                this.yaw = event.alpha;
                this.pitch = event.beta;
                this.roll = event.gamma;
                方向改变(this.yaw, this.pitch, this.roll);
            }
        });
    }

    get 可用() {
        return this.enabled;
    }

    set 可用(是否可用) {
        this.enabled = 是否可用;
    }

    get 俯仰角() {
        return this.pitch;
    }

    get 横滚角() {
        return this.roll;
    }

    get 偏航角() {
        return this.yaw;
    }

    get 倾斜角() {
        return Math.degrees(Math.atan2(this.pitch, this.roll));
    }

    取屏幕旋转角度() {
        switch (window.orientation) {
            case 0:
                return 0;
            case 90:
                return 90;
            case 180:
                return 180;
            case -90:
                return 270;
            default:
                return 0;
        }
    }
}

class 光线传感器 {
    constructor(光线改变) {
        if ('AmbientLightSensor' in window) {

            this.sensor = new AmbientLightSensor();
            this.sensor.onerror = (error) => {
                throw 'Sensor error:' + error;
            };
            this.sensor.onreading = () => {
                光线改变(this.sensor.illuminance);
            };
            this.sensor.start();
        } else {
            throw "你的设备不支持光线传感器";
        }
    }

    get 有效() {

        return 'AmbientLightSensor' in window;
    }
}

class 悬浮窗 {
    constructor() {
        this.fw = document.createElement('div');
        this.fw.style.position = "absolute";
        this.isShow = false;
        this.X坐标 = 0;
        this.Y坐标 = 0;
        this.fw.style.zIndex = 999999;
        document.body.appendChild(this.fw);
        this.被点击 = null;
        this.隐藏();
    }

    set 可否移动(可否) {
        if (可否) {
            setFloatingWindowMove(this.fw, this.被点击 || (() => {}));
        }
    }

    set 可获取焦点(可否) {
        this.fw.style.pointerEvents = 可否 ? "auto" : 'none';
    }

    set 组件(欲加载容器) {
        this.fw.innerHTML = 欲加载容器;
    }

    set X坐标(x) {
        this.fw.style.left = x + "px";
    }

    get X坐标() {
        return this.fw.style.left;
    }

    set Y坐标(y) {
        this.fw.style.top = y + "px";
    }

    get 坐标() {
        return this.fw.style.top;
    }

    隐藏() {
        this.fw.style.display = "none";
        this.isShow = false;
    }

    显示() {
        this.fw.style.display = "block";
        this.isShow = true;
    }

    关闭() {
        document.body.removeChild(this.fw);
    }

    取组件() {
        return this.fw;
    }

    切换() {
        if (this.isShow == true) {
            this.隐藏()
        } else {
            this.显示();
        }
    }
}

function setFloatingWindowMove(oDiv, onclickCallBack) {

    var disX, moveX, L, T, starX, starY, starXEnd, starYEnd;

    let beforeX, beforeY;

    oDiv.addEventListener('touchstart', function(e) {

        beforeX = this.offsetLeft;
        beforeY = this.offsetTop;

        e.preventDefault();

        disX = e.touches[0].clientX - this.offsetLeft;
        disY = e.touches[0].clientY - this.offsetTop;

        starX = e.touches[0].clientX;
        starY = e.touches[0].clientY;
    });

    oDiv.addEventListener('touchmove', function(e) {
        L = e.touches[0].clientX - disX;
        T = e.touches[0].clientY - disY;
        starXEnd = e.touches[0].clientX - starX;
        starYEnd = e.touches[0].clientY - starY;
        if (L < 0) {

            L = 0;
        } else if (L > document.documentElement.clientWidth - this.offsetWidth) {
            L = document.documentElement.clientWidth - this.offsetWidth;
        }
        if (T < 0) {

            T = 0;
        } else if (T > document.documentElement.clientHeight - this.offsetHeight) {
            T = document.documentElement.clientHeight - this.offsetHeight;
        }
        moveX = L + 'px';
        moveY = T + 'px';
        this.style.left = moveX;
        this.style.top = moveY;
    });

    oDiv.addEventListener('touchend', function() {

        if (beforeX === this.offsetLeft && beforeY === this.offsetTop) {

            onclickCallBack();
        }
    });
}

function 信息框(信息) {
    alert(信息);
}

class XML解析器 {
    parser = null;

    载入XML(XML文本) {
        try {
            this.parser = org.xmlpull.v1.XmlPullParserFactory.newInstance().newPullParser({
                size: 8192
            });
            this.parser.setInput(XML文本);
            if (this.parser.getEventType() == 1) {
                return false;
            }
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true
    }

    get 当前解析位置() {
        try {
            return this.parser.getEventType;
        } catch (e) {
            return -1;
        }
    }

    get 当前节点名() {
        let name = this.parser.getName();
        return name != null ? name : "";
    }

    get 当前节点内容() {
        let name = this.parser.getText();
        return name != null ? name : "";
    }

    get 属性数量() {
        return this.parser.getAttributeCount();
    }

    取属性名(索引) {
        let name = this.parser.getAttributeName(索引);
        return name != null ? name : "";
    }

    取属性内容(索引) {
        let value = this.parser.getAttributeValue(索引);
        return value != null ? value : "";
    }

    解析() {
        try {
            return this.parser.next();
        } catch (e) {
            throw e.message;
        }
    }
}

class XML合成器 {
    serializer = null;
    writer = null;

    constructor() {
        try {
            this.serializer = org.xmlpull.v1.XmlPullParserFactory.newInstance().newSerializer();
        } catch (e) {
            throw e.message;
        }
    }

    开始XML文档(文档编码 = "utf-8") {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.setOutput(this.writer);
            this.serializer.startDocument(文档编码, true);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    结束XML文档() {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.endDocument();
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    开始节点(节点名称) {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.startTag(null, 节点名称);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    添加节点属性(属性名, 属性内容) {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.attribute(null, 属性名, 属性内容);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    置节点内容(内容) {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.text(内容);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    添加注释(内容) {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.comment(内容);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    结束节点(节点名称) {
        if (this.serializer == null) {
            return false;
        }
        try {
            this.serializer.endTag(null, 节点名称);
        } catch (e) {
            console.error(e.message);
            return false;
        }
        return true;
    }

    导出文本() {
        if (this.writer != null) {
            let xml = this.writer.toString();
            return xml;
        }
        return "";
    }
}

var 真 = true;
var 假 = false;

function 信息框() {
    let args = Array.prototype.slice.call(arguments, 0);
    let 对话框1 = new 对话框();
    对话框1.按钮1 = "确定";
    if (args.length == 1) {
        对话框1.信息 = args[0];
    } else if (args.length == 2) {
        对话框1.标题 = args[0];
        对话框1.信息 = args[1];
    }
    对话框1.显示();
}

function 弹出提示(信息, 时间 = 4000) {
    mdui.snackbar({
        message: 信息,
        timeout: 时间
    });
}

class 对话框 {
    标题 = "";
    信息 = "";
    按钮1 = "";
    按钮2 = "";
    按钮3 = "";
    按钮1被单击 = () => {};
    按钮2被单击 = () => {};
    按钮3被单击 = () => {};
    可取消 = 真;

    constructor() {
        let args = Array.prototype.slice.call(arguments, 0);
        if (args.length == 3) {
            this.标题 = args[0];
            this.信息 = args[1];
            this.按钮1 = args[2];
        }
    }

    set 组件(ele) {
        this.信息 = ele;
    }

    get 组件() {
        return this.信息;
    }

    置对话框布局(欲设置组件) {
        this.组件 = 欲设置组件;
    }

    显示() {
        let btns = [];
        if (this.按钮1 != "") {
            btns.push({
                text: this.按钮1,
                onClick: (inst) => {
                    this.按钮1被单击();
                }
            });
        }
        if (this.按钮2 != "") {
            btns.push({
                text: this.按钮2,
                onClick: (inst) => {
                    this.按钮2被单击();
                }
            });
        }
        if (this.按钮3 != "") {
            btns.push({
                text: this.按钮3,
                onClick: (inst) => {
                    this.按钮3被单击();
                }
            });
        }
        mdui.dialog({
            title: this.标题,
            content: this.信息,
            buttons: btns,
            modal: this.可取消 ? 假 : 真,
            closeOnEsc: this.可取消,
            history: this.可取消
        });
    }
}

async function $引入(src) {
    if (src.结尾为("js")) {
        let script = document.createElement("script")
        script.src = src
        document.body.appendChild(script)
        await script.onload
    } else if (src.结尾为("form")) {
        await 结绳中文编程语法解析器.form转js(src)
    }
}

async function $布局(src) {
    if (src.结尾为("css")) {
        let link = document.createElement('link')
        link.type = 'text/css'
        link.rel = 'stylesheet'
        link.href = url
        let head = document.getElementsByTagName('head')[0]
        head.appendChild(link)
        await link.onload
    } else if (src.结尾为("sly")) {
        await 结绳中文编程语法解析器.sly转html(src)
    }
}

function removeComments(codes) { //去注释
    let {
        replacedCodes,
        matchedObj
    } = replaceQuotationMarksWithForwardSlash(codes);

    replacedCodes = replacedCodes.replace(/(\s*(?<!\\)\/\/.*$)|(\s*(?<!\\)\/\*[\s\S]*?(?<!\\)\*\/)/mg, '');
    Object.keys(matchedObj).forEach(k => {
        replacedCodes = replacedCodes.replace(k, matchedObj[k]);
    });

    return replacedCodes;

    function replaceQuotationMarksWithForwardSlash(codes) {
        let matchedObj = {};
        let replacedCodes = '';

        let regQuotation = /(?<!\\)('|"|`).*?(?<!\\)\1/mg;
        let uniqueStr = 'QUOTATIONMARKS' + Math.floor(Math.random() * 10000);

        let index = 0;
        replacedCodes = codes.replace(regQuotation, function(match) {
            let s = uniqueStr + (index++);
            matchedObj[s] = match;
            return s;
        });

        return {
            replacedCodes,
            matchedObj
        };
    }
}
var window窗口 = window
var 文档 = document
class 结绳中文编程语法解析器 {
    static async form转js(src) {
        try {
            eval(`
        class checkStaticBlock{
        static {
        //check
        }
        }
        `)
        } catch (e) {
            信息框("兼容性问题：<br>您的浏览器不支持静态初始化块!")
            throw "兼容性问题：您的浏览器不支持静态初始化块!"
            return
        }
        let code = await (await fetch(src)).text()
        var lines = removeComments(code).split("\n");
        let 结果 = ""
        let inClass = 假
        let inFun = 假
        let inFunNum = 0
        let 事件前缀 = ""
        let 最外层事件前缀 = ""
        for (var index21037 = 0; index21037 < lines.length; index21037++) {
            var line = lines[index21037];
            line = line.trim();
            if (line.length == 0) {
                continue;
            }
            line = line.替换("父对象", "").替换("本对象", "").替换("ID取子元素", "getElementById").替换("创建 ", "new ")
            if (line.开头为("结束 ")) {
                if (line == "结束 类") {
                    inClass = 假
                } else if (line == "结束 方法" && inFunNum == 1) {
                    inFun = 假
                    inFunNum--
                } else if (line == "结束 事件") {
                    if ((inFun || (inClass && inFun)) && (最外层事件前缀 == 事件前缀)) {
                        结果 += "}\n"
                    }
                    if (inFunNum == 1) {
                        inFun = 假
                        inFunNum--
                    }
                    事件前缀 = 最外层事件前缀
                }
                结果 += "}\n"
            } else if (line.开头为("事件 ") || line.开头为("异步事件 ")) {
                inFun = 真
                inFunNum++
                let 参数 = line.替换("异步事件 ", "").替换("事件 ", "").分割(":")
                let 传入参数 = "(" + 去除强类型(参数[1].分割("(")[1].slice(0, -1)) + ")"
                事件前缀 = 被使用检测(参数[0]) + "." + 使用检测(参数[1].分割("(")[0])
                if ((inFun || (inClass && inFun)) && inFunNum == 1) {
                    最外层事件前缀 = 事件前缀
                }
                结果 += (((inFun || (inClass && inFun)) && inFunNum == 1) ? "static {\n" : "") + 事件前缀 + " = " + ((line.开头为("异步事件 ")) ? "async " : "") + "function" + 传入参数 + "{\n"
            } else if (line.开头为("如果 ") && line.结尾为(" 则")) {
                结果 += "if(" + line.替换("如果 ", "").替换(" 则", "") + "){\n"
            } else if (line.开头为("又如果 ") && line.结尾为(" 则")) {
                结果 += "}else if(" + line.替换("又如果 ", "").替换(" 则", "") + "){\n"
            } else if (line == "否则") {
                结果 += "}else{"
            } else if (line.开头为("方法 ") || line.开头为("异步方法 ")) {
                inFun = 真
                结果 += (line.开头为("异步方法 ") ? "async " : "") + ((inFun || (inClass && inFun)) ? "function " : "") + line.替换("异步方法 ", "").替换("方法 ", "").分割("(")[0] + "(" + 去除强类型(line.替换("异步方法 ", "").替换("方法 ", "").分割("(")[1].分割(")")[0]) + "){\n"
            } else if (line.开头为("类 ")) {
                inClass = 真
                结果 += line.替换("类 ", "class ").替换(" 继承 js5d核心支持库", "").替换("继承", "extends") + "{\n"
            } else if (line.开头为("变量 ")) {
                if (!(line.包含("window窗口类") || line.包含("文档类"))) {
                    结果 += ((inFun || (inClass && inFun)) ? "var " : "") + line.分割("为")[0].替换("变量", "").trim() + " = " + line.分割("=")[1].replace(/\(.*\) 到对象/g, "").trim() + "\n"
                }
            } else {
                结果 += line.替换("等待 ", "await ") + "\n"
            }
        }
        控制台.输出(结果)
        eval(结果)

        function 使用检测(str) {
            let list = {
                "被单击": "onclick",
                "载入完成": "onloadMain"
            }
            if (list[str]) {
                return list[str]
            } else {
                return str
            }
        }

        function 被使用检测(str) {
            if (document.getElementById(str)) {
                return "document.getElementById('" + str + "')"
            } else {
                return str
            }
        }

        function 去除强类型(input) {
            // 使用正则表达式匹配形如 "x 为 y" 的模式，并捕获 x 部分
            const regex = /([\w\u4e00-\u9fa5]+)\s*为\s*.*?(?=(,\s*[\w\u4e00-\u9fa5]+\s*为\s*|$))/g;
            let matches;
            const keys = [];

            // 使用全局匹配获取所有符合条件的匹配项
            while ((matches = regex.exec(input)) !== null) {
                keys.push(matches[1]);
            }

            return keys.join(',');
        }
    }

    static async sly转html(src) {
        let code = await (await fetch(src)).text()
        let 结果 = parseCustomFormat(code)
        控制台.输出(JSON.stringify(结果))
        结果 = jsonToHtml(结果)
        控制台.输出(结果)
        文档.getElementById("output").innerHTML = 结果;
        updateElementsByTypeAndAttribute("button");
        for (let i123 = 1; i123 <= 6; i123++) {
            updateElementsByTypeAndAttribute("h" + i123);
        }

        function parseCustomFormat(input) {
            let stack = [];
            let currentObject = null;

            // 用于临时存储键值对
            let currentKey = '';
            let currentValue = '';
            let isInChild = false;

            const lines = input.split('\n').map(line => line.trim()).filter(line => line.length > 0);

            lines.forEach(line => {
                // 检查是否是子元素的开始
                if (line.endsWith('{')) {
                    // 如果当前对象不存在，初始化为一个新对象
                    if (!currentObject) {
                        currentObject = {};
                    }
                    // 进入子元素
                    if (!currentObject['子元素']) {
                        currentObject['子元素'] = [];
                    }
                    // 创建新的子元素对象并推入栈
                    const newChild = {};
                    currentObject['子元素'].push(newChild);
                    stack.push(currentObject);
                    currentObject = newChild;
                    isInChild = true;
                    return;
                }

                // 检查是否是子元素的结束
                if (line === '}') {
                    if (stack.length > 0) {
                        currentObject = stack.pop();
                    }
                    isInChild = false;
                    return;
                }

                // 处理键值对
                if (line.includes('=')) {
                    const [key, value] = line.split('=').map(part => part.trim());
                    if (key && value) {
                        currentKey = key;
                        currentValue = value.replace(/["']/g, '').trim();
                        if (currentValue.match(/^\d+$/)) {
                            currentValue = parseInt(currentValue, 10);
                        }
                        currentObject[currentKey] = currentValue.替换(",", "");
                    }
                } else if (line.includes(',')) {
                    if (!line.包含("=")) {
                        currentObject["类型"] = line.替换(",", "")
                    } else {
                        const [key, value] = line.split(',').map(part => part.trim());
                        if (key && value) {
                            currentKey = key;
                            currentValue = value.replace(/["']/g, '').trim();
                            currentObject[currentKey] = currentValue.替换(",", "");
                        }
                    }
                }
            });

            // 最后返回解析出的对象
            return currentObject;
        }

        function jsonToHtml(json) {
            let 替换列表 = {
                "高度": "height",
                "宽度": "width",
                "名称": "id",
                "内容": "value",
                "js5d.大标题": "h1",
                "js5d.div": "div",
                "js5d.html按钮": "button"
            };
            if (!json.类型) {
                json = json.子元素[0]
            }
            let 标签名 = json.类型;
            if (替换列表[json.类型] && typeof 替换列表[json.类型] === 'string') {
                标签名 = 替换列表[json.类型];
            }

            let html = `<${标签名}`;
            let style = "";

            for (let [key, value] of Object.entries(json)) {
                if (key === "类型" || key === "id") continue; // 跳过类型键

                let 实际键 = (替换列表[key] && typeof 替换列表[key] === 'string') ? 替换列表[key] : key;

                if (实际键 !== "子元素") {
                    if (value !== undefined && 实际键 in document.createElement("div").style) {
                        // 如果是样式属性，则添加到样式字符串中
                        style += `${实际键}: ${value.替换("-1","100%").替换("-2","auto")}; `;
                    } else {
                        // 其他属性正常添加到html中
                        html += ` ${实际键}="${(实际键 === '内容') ? escapeHtml(value) : value}"`;
                    }
                }
            }

            if (style) {
                html += ` style="${style.trim()}"`;
            }

            html += '>';

            if (json.子元素 && Array.isArray(json.子元素)) {
                // 如果有子元素，则递归调用jsonToHtml函数处理子元素
                for (const child of json.子元素) {
                    html += jsonToHtml(child);
                }
            }

            html += `</${标签名}>`;

            return html;
        }

        function escapeHtml(text) {
            const map = {
                '&': '&amp;',
                '<': '&lt;',
                '>': '&gt;',
                '"': '&quot;',
                "'": '&#039;'
            };
            return text.replace(/[&<>"']/g, function(m) {
                return map[m];
            });
        }

        function updateElementsByTypeAndAttribute(elementType) {
            // 获取所有指定类型的元素
            const elements = document.querySelectorAll(elementType);

            elements.forEach(element => {
                // 获取属性值
                const attrValue = element.getAttribute("value");

                // 检查属性值是否包含目标值
                if (attrValue) {
                    element.textContent = attrValue;
                    element.value = attrValue;
                }
            });
        }
    }
}